<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<script>
    function previewImage() {
        var fileReader = new FileReader();
        fileReader.readAsDataURL(document.changeProfiles.file.files[0]);
        fileReader.onload = function(oFREvent) {
            document.getElementById("image").src = oFREvent.target.result;
        };
    }
    ;

    function resetPassword() {

        oFormObject = document.forms['changeProfiles'];
        oFormObject.elements["password"].value = 'abc123';


    }
</script>

<c:if test="${userEdit!=null}">
    <form action="/JudiBlog/usermanage?action=update&userid=${userEdit.userID}" name="changeProfiles" method="post">             <!--     enctype="multipart/form-data"-->
        <table id="tbl_edit_user">
            <thead>
                <tr>
                    <th colspan="2">Information</th>
                </tr>
            </thead>
            <tbody>
                <tr id="user_id">
                    <td>User ID: </td>
                    <td>${userEdit.getUserID()}</td>
                </tr>
                <tr>
                    <td>User Name: </td>
                    <c:choose>
                        <c:when test ="${userEdit.getUserName() != null}">
                            <td><input type="text" value="${userEdit.getUserName()}" name="userName" disabled/></td>
                            </c:when>
                            <c:otherwise>
                            <td><input type="text" value="" name="userName"/></td>
                            </c:otherwise>
                        </c:choose>

                </tr>
                <tr>
                    <td>Full name: </td>
                    <td><input type="text" value="${userEdit.getFullName()}" name="fullName"/></td>
                </tr>
                <tr>
                    <td>Password: </td>
                    <td><input type="password" value="${userEdit.getPwd()}" name="password"/>   <a href="#" onclick="resetPassword()">Reset pass</a> </td>
                </tr>
                <tr>
                    <td>Role: </td>
                    <td><select name="role">
                            <option value="1" ${userEdit.getRole().getRoleName() =='Administrator' ? 'selected':''} >Administrator</option>
                            <option value="2" ${userEdit.getRole().getRoleName() =='SuperModerator' ? 'selected':''}>SuperModerator</option>
                            <option value="3" ${userEdit.getRole().getRoleName() =='Moderator' ? 'selected':''}>Moderator</option>
                            <option value="4" ${userEdit.getRole().getRoleName() =='Member' ? 'selected':''}>Member</option>
                        </select>
                    </td>
                </tr>
                <tr>
                    <td>Birth day: </td>
                    <td><input type="date" value="${userEdit.getBirthday()}" name="birthday"/></td>                                    
                </tr>
                <tr>
                    <td>Gender: </td>
                    <td>
                        <select name="gender">
                            <option value="male" ${userEdit.isGender() ? 'selected' : ''}>Male</option>
                            <option value="female" ${userEdit.isGender() ? '' : 'selected'}>Female</option>
                        </select>
                    </td>
                </tr>
                <tr>
                    <td>Address: </td>
                    <td><input type="text" value="${userEdit.getAddress()}" name="address"/></td>   
                </tr>
                <tr>
                    <td>Email: </td>
                    <td><input type="text" value="${userEdit.getEmail()}" name="email"/></td>
                </tr>
                <tr>
                    <td>Phone number: </td>
                    <td><input type="text" value="${userEdit.getPhone()}" name="phone"/></td>
                </tr>
                <tr>
                    <td>Id Card </td>
                    <td><input type="text" value="${userEdit.getIdCard()}" name="IdCard"/></td>
                </tr>
                <tr id="btn">
            <input type="hidden" value="${userEdit.getUserID()}" name="userid"/>
            <td><input type="reset" name="submit" value="reset"></td>
            <td><input type="submit" name="action" value="Update"></td>
            </tr>
            </tbody>
        </table>
    </form>
</c:if>
